package com.cloud.school.app.model;

import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Data
@ApiModel("专业信息")
public class MajorModel {
    /**
     * 专业id
     */
    @ApiModelProperty("专业id")
    private Long id;

    /**
     * 学校id
     */
    @ApiModelProperty("学校id")
    private Long collegeId;

    /**
     * 专业名
     */
    @ApiModelProperty("专业名")
    private String name;

    /**
     * 专业编码
     */
    @ApiModelProperty("专业编码")
    private String code;

    @ApiModelProperty("专业图片(图片id)")
    private Long image;

    @ApiModelProperty("专业图片")
    private ImageModel imageModel;

    /**
     * 创建人
     */
    @ApiModelProperty("创建人")
    private Long createUid;

    /**
     * 创建时间
     */
    @ApiModelProperty("创建时间")
    private Long createTime;

    @ApiModelProperty("注册人数")
    private long registerNum;

    @ApiModelProperty("头像id(用数组包装)")
    private List<Long> images;

    @ApiModelProperty("头像对象(用数组包装)")
    private List<ImageModel> imageModels;

    public List<Long> getImages() {
        return Lists.newArrayList(image);
    }

    public List<ImageModel> getImageModels() {
        return Lists.newArrayList(imageModel);
    }

    public void setImages(List<Long> images) {
        if (this.image == null && !CollectionUtils.isEmpty(images)) {
            this.image = images.get(0);
        }
    }
}